<template>
  <div>
    <Modal
      :mask-closable="false"
      v-model="deviceVisible"
      width="800"
      :title="titleTop"
      class="modal-content-layout"
    >
      <Form
        ref="deviceForm"
        :model="formTop"
        label-position="top"
        :rules="validateDevice"
      >
        <Row :gutter="16">
          <Col :span="12">
            <!--班组-->
            <FormItem label="班组" prop="team">
              <Select
                v-model="formTop.team"
                clearable
                @on-change="teamChange"
                :placeholder="`${$t('common.selectInfo')}`"
              >
                <Option
                  v-for="(item, index) of teamList"
                  :value="item.team"
                  :key="index"
                  :label="item.team"
                >
                </Option>
              </Select>
            </FormItem>
          </Col>
          <!--班次-->
          <Col :span="12">
            <FormItem label="班次" prop="shift">
              <Select
                v-model="formTop.shift"
                clearable
                :placeholder="`${$t('common.selectInfo')}`"
                @on-change="shiftChange"
              >
                <Option
                  v-for="(item, index) of shiftList"
                  :value="item.shift"
                  :key="index"
                  :label="item.shift"
                >
                </Option>
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col :span="12">
            <FormItem label="报修人" prop="repairApplicant">
              <Input
                readonly
                v-model="formTop.repairApplicant"
                :placeholder="`${$t('common.inputInfo')}报修人`"
              />
            </FormItem>
          </Col>
          <Col :span="12">
            <FormItem label="报修电话" prop="repairHotline">
              <Input
                maxlength="50"
                v-model="formTop.repairHotline"
                :placeholder="`${$t('common.inputInfo')}报修电话`"
                clearable
              />
            </FormItem>
          </Col>
          <!-- <Col :span="12">
            <FormItem :label="$t('fault.FaultTime')" prop="faultTime">
              <DatePicker
                :options="optionsdate"
                :disabled="inputEquipmentInfo"
                v-model="formTop.faultTime"
                type="datetime"
                format="yyyy-MM-dd HH:mm:ss"
                :placeholder="`${$t('common.selectInfo')}${$t(
                  'fault.FaultTime'
                )}`"
              >
              </DatePicker>
            </FormItem>
          </Col> -->
        </Row>
        <Row :gutter="16">
          <Col :span="12">
            <FormItem label="工装编号" prop="moldCode">
              <Select
                v-model="formTop.moldCode"
                filterable
                :loading="selectLoading"
                @on-change="getMoldInfoChange"
                :remote-method="getMoldInfo"
                clearable
                :placeholder="`${$t('common.selectInfo')}`"
              >
                <Option
                  v-for="(item, index) of moldInfoList"
                  :value="item.moldCode"
                  :key="index"
                  :label="item.moldCode"
                >
                </Option>
              </Select>
            </FormItem>
          </Col>
          <Col :span="12">
            <FormItem label="工装名称" prop="moldName">
              <Input
                maxlength="50"
                v-model="formTop.moldName"
                readonly
                :placeholder="`${$t('common.inputInfo')}工装名称`"
              />
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col :span="12">
            <FormItem label="是否验收" prop="acceptanceStatus">
              <Select
                v-model="formTop.acceptanceStatus"
                :placeholder="`${$t('common.selectInfo')}是否验收`"
              >
                <Option value="0" label="新模"></Option>
                <Option value="1" label="常规模"></Option>
              </Select>
            </FormItem>
          </Col>
          <Col :span="12">
            <FormItem label="工装所在设备编号" prop="punchNumber">
              <Input
                v-model="formTop.punchNumber"
                maxlength="50"
                :placeholder="`${$t('common.inputInfo')}工装所在设备编号`"
                clearable
              />
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col :span="12">
            <FormItem label="压机编号" prop="pressNumber">
              <Input
                maxlength="50"
                v-model="formTop.pressNumber"
                :placeholder="`${$t('common.inputInfo')}压机编号`"
                clearable
              />
            </FormItem>
          </Col>
          <Col :span="12">
            <FormItem label="焊机编号" prop="weldingMachineNumber">
              <Input
                maxlength="50"
                v-model="formTop.weldingMachineNumber"
                :placeholder="`${$t('common.inputInfo')}焊机编号`"
                clearable
              />
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <!-- <Col :span="12">
          <FormItem label="冲速" prop="chongsu">
            <Input v-model="formTop.chongsu" :placeholder="`${$t('common.inputInfo')}冲速`" clearable />
          </FormItem>
          </Col> -->
          <Col :span="12">
            <FormItem :label="$t('fault.FaultTime')" prop="faultTime">
              <DatePicker
                :options="optionsdate"
                :disabled="inputEquipmentInfo"
                v-model="formTop.faultTime"
                type="datetime"
                format="yyyy-MM-dd HH:mm:ss"
                :placeholder="`${$t('common.selectInfo')}${$t(
                  'fault.FaultTime'
                )}`"
              >
              </DatePicker>
            </FormItem>
          </Col>
          <Col :span="12">
            <FormItem label="冲压材料" prop="stampingMaterials">
              <Input
                maxlength="50"
                v-model="formTop.stampingMaterials"
                :placeholder="`${$t('common.inputInfo')}冲压材料`"
                clearable
              />
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col :span="12">
            <FormItem label="冲压用油" prop="stamping">
              <Select
                v-model="formTop.stamping"
                clearable
                :placeholder="`${$t('common.selectInfo')}冲压用油`"
              >
                <Option
                  v-for="(item, index) of cyyyList"
                  :value="item.value"
                  :key="index"
                  :label="item.value"
                >
                </Option>
              </Select>
            </FormItem>
          </Col>
          <Col :span="12">
            <FormItem label="异常现象" prop="abnormalPhenomena">
              <!-- <cascaderMulti v-model="formTop.abnormalPhenomena" :data="abnormalList"
              :placeholder="`${$t('common.selectInfo')}异常现象`"></cascaderMulti> -->
              <!-- {{formTop.abnormalPhenomena}} -->
              <Cascader
                v-model="formTop.abnormalPhenomena"
                :data="abnormalList"
                :placeholder="`${$t('common.selectInfo')}异常现象`"
              ></Cascader>

              <!-- <Select multiple v-model="formTop.abnormalPhenomena" >
              <Option v-for="item in abnormalType" :value="item.label" :label="item.label" :key="item.value">
              </Option>
            </Select> -->
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col :span="12">
            <FormItem label="紧急程度" prop="urgencyLevel">
              <Select
                v-model="formTop.urgencyLevel"
                :disabled="inputEquipmentInfo"
                :placeholder="`${$t('common.selectInfo')}紧急程度`"
              >
                <Option
                  v-for="item in levels"
                  :value="item.value"
                  :label="item.label"
                  :key="item.value"
                >
                </Option>
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col :span="24">
            <!--报修电话-->
            <FormItem
              label="工装(产品)异常情况描述"
              prop="exceptionDescription"
            >
              <Input
                maxlength="30"
                :disabled="inputEquipmentInfo"
                v-model="formTop.exceptionDescription"
                clearable
              />
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16">
          <Col :span="12">
            <FormItem label="是否附样" prop="sampleAttached">
              <RadioGroup
                v-model="formTop.sampleAttached"
                :disabled="inputEquipmentInfo"
              >
                <Radio
                  :label="item.value"
                  v-for="item in effects"
                  :key="item.value"
                >
                  {{ item.label }}
                </Radio>
              </RadioGroup>
            </FormItem>
          </Col>
          <Col :span="12" :style="{ marginTop: '0px', display: 'flex' }">
            上传附件：
            <Upload
              :show-upload-list="false"
              accept="image/*"
              :format="['jpg', 'jpeg', 'png']"
              :before-upload="handleBeforeUpload"
              type="drag"
              action=""
              style="display: inline-block; width: 58px"
            >
              <div style="width: 58px; height: 58px; line-height: 58px">
                <Icon type="ios-camera" size="20"></Icon>
              </div>
            </Upload>
            <div
              class="demo-upload-list"
              v-for="(item, index) in uploadList"
              :key="index"
            >
              <img :src="util.filePathToUrl(item.filePath)" />
              <Icon
                type="ios-close-circle"
                class="delIcon"
                @click="deleteImg(index)"
              />
            </div>
          </Col>
        </Row>
        <!-- 故障现象
        <Row :gutter="16">
          <Col :span="12">
          <FormItem :label="$t('fault.Description')" prop="faultMessage">
            <Input type="textarea" :rows="4" :maxlength="200" :disabled="inputEquipmentInfo"
              :placeholder="`${$t('common.inputInfo')}${$t('fault.Description')}`" v-model="formTop.faultMessage"
              clearable />
            <searchAndSelectComponent v-if="deviceVisible" :list="faultMessageList"
              :field="{ label: 'label', value: 'label' }" :remote-method="handleRemotefaultMessage"
              @change="faultMessageChange" />
          </FormItem>
          </Col>
        </Row> -->
      </Form>
      <div slot="footer">
        <Button type="default" @click="handleCancel">{{
          $t("common.Cancle")
        }}</Button>

        <Button type="primary" :loading="loadingVisible" @click="handleOk">{{
          tarGetid ? $t("fault.Submit") : $t("maintenance.Confirmed")
        }}</Button>
      </div>
    </Modal>
  </div>
</template>

<script>
import moment from "moment";
import { getMoldInfoList } from "@/api/moldManagement/moldOutApply.js";
// import searchAndSelectComponent from "@/components/searchAndSelect.vue";
import { getTeamList } from "@/api/system/production-input/production-shift.js";
import { getAbnormalPhenomenaList } from "@/api/moldManagement/abnormalPhenomenaList.js";


export default {
  name: "addModal",
  // components: { searchAndSelectComponent },
  data() {
    return {
      selectLoading: false,
      cyyyList: [],
      optionsdate: {
        disabledDate(date) {
          return date && date.getTime() > Date.now();
        },
      },
      inputEquipmentInfo: false,
      deviceVisible: false,
      loadingVisible: false,
      searchLoading: false,
      isFirst: false,
      isFirst2: false,
      titleTop: this.$t("fault.CreateAWorkOrder"),
      tarGetid: "",
      target: "",
      teamList: [],
      shiftList: [],
      formTop: {
        deviceMId: "",
        deviceNo: "",
        deviceName: "",
        faultTime: "",
        maintainApplyDate: "",
        faultMessage: "",
        maintainApplyPhone: "",
        maintainGrade: "",
        moldCode: "",
      },
      moldInfoList: [],
      faultMessageList: [],
      validateDevice: {
        team: [
          {
            required: true,
            message: `${this.$t("common.selectInfo")}班组`,
            trigger: "change",
          },
        ],
        shift: [
          {
            required: true,
            message: `${this.$t("common.selectInfo")}班次`,
            trigger: "change",
          },
        ],
        moldCode: [
          {
            required: true,
            message: `${this.$t("common.selectInfo")}工装编号`,
            trigger: "change",
          },
        ],
        moldName: [
          {
            required: true,
            message: `${this.$t("common.selectInfo")}工装名称`,
            trigger: "change",
          },
        ],
        acceptanceStatus: [
          {
            required: true,
            type: "string",
            message: `${this.$t("common.selectInfo")}是否验收`,
            trigger: "change",
          },
        ],
        urgencyLevel: [
          {
            required: true,
            type: "string",
            message: `${this.$t("common.selectInfo")}紧急程度`,
            trigger: "change",
          },
        ],
        abnormalPhenomena: [
          {
            required: true,
            type: "array",
            message: `${this.$t("common.selectInfo")}异常现象`,
            trigger: "change",
          },
        ],
        repairHotline: [
          {
            required: false,
            message: "请输入正确的电话号码",
            pattern:
              /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/,
            trigger: ["blur"],
            transform(value) {
              return value.trim();
            },
          },
        ],
        faultTime: [
          {
            required: true,
            type: "date",
            message: `${this.$t("common.selectInfo")}${this.$t(
              "fault.FaultTime"
            )}`,
            trigger: "change",
          },
        ],
        maintainApplyDate: [
          {
            required: true,
            type: "date",
            message: `${this.$t("common.selectInfo")}${this.$t(
              "fault.RenovationTime"
            )}`,
            trigger: "change",
          },
        ],
        faultMessage: [
          {
            required: true,
            message: `${this.$t("common.inputInfo")}${this.$t(
              "fault.Description"
            )}`,
            trigger: "change",
          },
        ],

        maintainGrade: [
          {
            required: true,
            type: "number",
            message: `${this.$t("common.selectInfo")}${this.$t(
              "fault.Evergreen"
            )}`,
            trigger: "change",
          },
        ],
        affectProductionFlag: [
          {
            required: true,
            type: "number",
            message: `${this.$t("common.selectInfo")}${this.$t(
              "fault.ImpactProduction"
            )}`,
            trigger: "change",
          },
        ],
      },
      faultCodeList: [],
      numberList: [],
      numberList2: [],
      levels: [
        { label: "特急", value: "1" },
        { label: "紧急", value: "2" },
        { label: "一般", value: "3" },
      ],
      abnormalType: [
        { label: "工装异常", value: "1" },
        { label: "品质异常", value: "2" },
      ],
      effects: [
        { label: "是", value: "1" },
        { label: "否", value: "2" },
      ],
      uploadList: [],
      // abnormalList: [
      //   {
      //     value: "工装异常",
      //     label: "工装异常",
      //     children: [
      //       { value: "送料异常", label: "送料异常" },
      //       { value: "零件损坏", label: "零件损坏" },
      //       { value: "切废异常", label: "切废异常" },
      //       { value: "检测异常", label: "检测异常" },
      //       { value: "异物进入", label: "异物进入" },
      //       { value: "气缸异常", label: "气缸异常" },
      //       { value: "冒废", label: "冒废" },
      //       { value: "回转异常", label: "回转异常" },
      //       { value: "带料", label: "带料" },
      //     ],
      //   },
      //   {
      //     value: "品质异常",
      //     label: "品质异常",
      //     children: [
      //       { value: "拉毛", label: "拉毛" },
      //       { value: "外观不良", label: "外观不良" },
      //       { value: "颗粒度不良", label: "颗粒度不良" },
      //       { value: "叠厚不良", label: "叠厚不良" },
      //       { value: "印痕", label: "印痕" },
      //       { value: "轮廓度不良", label: "轮廓度不良" },
      //       { value: "焊后槽口紧", label: "焊后槽口紧" },
      //       { value: "尺寸不良", label: "尺寸不良" },
      //       { value: "拉力不良", label: "拉力不良" },
      //       { value: "端跳不良", label: "端跳不良" },
      //       { value: "同轴度不良", label: "检测异常" },
      //       { value: "垂直度不良", label: "垂直度不良" },
      //       { value: "平面度不良", label: "平面度不良" },
      //       { value: "位置度不良", label: "位置度不良" },
      //       { value: "圆柱度不良", label: "圆柱度不良" },
      //       { value: "压入力不良", label: "压入力不良" },
      //     ],
      //   },
      // ],
      abnormalList:getAbnormalPhenomenaList(),
    };
  },
  mounted() {
    this.getTeam();
    this.axios({
      url: "/dms/faultCategory/dictList?name=冲压用油",
    }).then((res) => {
      this.cyyyList = res.data;
    });
  },
  methods: {
    getMoldInfoChange(val) {
      if (!val) {
        return;
      }
      this.formTop.moldCode = val;
      let res = this.moldInfoList.find((item) => item.moldCode === val);
      this.formTop.moldName = res.moldName;
    },
    handleRemotefaultMessage(value) {
      this.axios({
        method: "post",
        url: "/dms/dict/list",
        data: {
          code: "故障现象",
          pageSize: 999,
          pageNo: 1,
          value,
        },
      }).then((res) => {
        if (res.code === 200) {
          let list = res.data.list || [];
          this.faultMessageList = list.map((item) => {
            item.label =
              this.$i18n.locale === "zh_CN" ? item.value : item.enValue;
            return item;
          });
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true,
          });
        }
      });
    },
    faultMessageChange(row) {
      this.formTop.faultMessage = row.label;
    },
    getServerDate() {
      this.axios({
        method: "get",
        url: "/dms/common/date",
      }).then((res) => {
        if (res.code === 200) {
          //time
          this.formTop.maintainApplyDate = res.data.time;
          this.formTop.faultTime = res.data.time;
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true,
          });
        }
      });
    },
    //文件上传
    handleBeforeUpload(file) {
      let formData = new FormData();
      formData.append("dir", "device");
      formData.append("file", file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
      };
      this.axios({
        method: "post",
        url: "/fileServer/upload",
        data: formData,
        config,
      }).then((res) => {
        if (res.code == 200) {
          this.uploadList.push({
            fileName: res.data.fileName,
            fileUrl: res.data.fileUrl,
            filePath: res.data.filepath,
          });
        }
      });
      return false;
    },
    deleteImg(index) {
      this.uploadList.splice(index, 1);
    },
    async show(tarGetid) {
      this.target = "";
      this.formTop = {};
      this.$refs.deviceForm.resetFields();
      this.formTop = {
        repairApplicant: localStorage.getItem("ziyunFactoryPortalName"),
        faultTime: moment().format("YYYY-MM-DD HH:mm:ss"),
        maintainApplyDate: moment().format("YYYY-MM-DD HH:mm:ss"),
        repairHotline: window.localStorage.getItem("ziyunFactoryUserPhone"),
      };
      this.titleTop = this.$t("fault.CreateAWorkOrder");
      this.uploadList = [];
      this.numberList = [];
      this.numberList2 = [];
      this.isFirst = false;
      this.isFirst2 = false;
      if (tarGetid) {
        this.titleTop = this.$t("fault.ApplyForMaintenance");
        this.tarGetid = tarGetid;
        this.formTop.deviceMId = tarGetid;
        await this.handleRemote(tarGetid);
        this.$nextTick(() => {
          this.handleChangeWl(tarGetid);
        });
      }

      this.deviceVisible = true;
    },
    open(formTop, target, title) {
      this.target = target;
      this.formTop = {};
      this.$refs.deviceForm.resetFields();
      this.faultCodeList = [];
      const { faultTime, maintainApplyDate } = formTop;
      this.formTop = {
        ...formTop,
        faultTime: new Date(faultTime),
        maintainApplyDate: new Date(maintainApplyDate),
        username:
          formTop.maintainApplyByEmpno + "-" + formTop.maintainApplyByStr,
      };

      this.inputEquipmentInfo = true;
      this.titleTop = title;

      this.uploadList = [];
      this.numberList = [];
      this.numberList2 = [];
      this.isFirst = false;
      this.isFirst2 = false;

      this.deviceVisible = true;

      if (!formTop.id) {
        this.getServerDate();
      }

      this.$forceUpdate();
    },
    async edit(formTop, target) {
      this.formTop = {};
      this.target = target;
      this.$refs.deviceForm.resetFields();
      this.titleTop = this.$t("编辑工单");

      this.formTop = {
        ...formTop,
        repairApplicant: formTop.repairApplicant,
        // username: formTop.maintainApplyByEmpno + "-" + formTop.maintainApplyByStr,
        faultTime: new Date(formTop.faultTime),
        maintainApplyDate: new Date(formTop.maintainApplyDate),
        abnormalPhenomena: formTop.abnormalPhenomena.split(","),
        team: formTop.team,
        moldCode: formTop.moldCode,
      };
      await this.getMoldInfo(formTop.moldCode);

      this.getMoldInfoChange(this.formTop.moldCode);

      this.axios({
        method: "get",
        url: "/dms/productionShift/selectByTeam",
        params: { teamName: this.formTop.team },
      }).then((res) => {
        this.shiftList = res.data;
        this.formTop.shift = formTop.shift;

        this.deviceVisible = true;
      });

      if (!this.formTop.faultMessage) {
        this.formTop.faultMessage = "无";
      }

      this.inputEquipmentInfo = false;
      this.uploadList = formTop.uploadAttachments || [];

      this.numberList = [];
      this.isFirst = false;
      this.isFirst2 = false;
    },
    handleRemote(query) {
      if (query !== "") {
        this.searchLoading = true;
        let _query = query.split("-");
        if (Array.isArray(_query)) _query = _query[0];
        return this.axios({
          method: "get",
          url: "/dms/dmsDevice/deviceList",
          params: {
            deviceMId: _query,
            deviceNo: "",
            assetsNo: "",
            orgCode: "",
          },
        })
          .then((res) => {
            if (res.code === 200) {
              this.numberList = res.data.map((item) => {
                item.desc =
                  item.deviceMId + "-" + item.deviceNo + "-" + item.deviceName;
                return item;
              });
              this.numberList.forEach((val) => {
                if (val.deviceStatus === "3") {
                  val.disabled = true;
                }
              });
              if (this.isFirst2) {
                this.formTop.deviceMId = query;
              }
            } else {
              this.$Message.warning({
                content: res.msg,
                duration: 6,
                closable: true,
              });
            }
          })
          .finally(() => {
            this.searchLoading = false;
          });
      } else {
        this.numberList = [];
      }
    },
    handleChangeWl(val) {
      let obj;
      if (this.tarGetid) {
        obj = this.numberList.find((item) => item.deviceMId === val);
      } else {
        obj = this.numberList.find((item) => item.deviceMId === val.value);
      }
      if (obj) {
        this.formTop.deviceName = obj.deviceName || "";
        this.formTop.deviceNo = obj.deviceNo || "";
        this.formTop.deviceId = obj.deviceId || "";
        this.isFirst = true;
        this.getfaultCode(obj.id);
      }
    },
    getfaultCode(deviceId) {
      let params = {
        deviceId,
      };
      this.axios({
        method: "post",
        url: "/dms/knowledgeBase/queryKnowledgeList",
        data: params,
      }).then((res) => {
        if (res.code === 200) {
          this.faultCodeList = res.data;
        }
      });
    },
    handleCancel() {
      this.deviceVisible = false;
      this.loadingVisible = false;
    },
    handleOk() {
      this.$refs.deviceForm.validate(async (valid) => {
        if (valid) {
          let params = {
            createBy: window.localStorage.getItem("ziyunFactoryUserId"),
            ...this.formTop,
            faultTime: this.$moment(this.formTop.faultTime).format(
              "YYYY-MM-DD HH:mm:ss"
            ),
            abnormalPhenomena: this.formTop.abnormalPhenomena.join(","),
            uploadAttachments: this.uploadList || [],
          };
          const createOrder = () => {
            const diff = moment(this.formTop.faultTime).diff(
              moment(this.formTop.maintainApplyDate),
              "seconds"
            );
            if (diff > 0) {
              this.$Message.warning(`${this.$t("故障时间应小于等于报修时间")}`);
              return;
            }

            if (this.inputEquipmentInfo) {
              if (this.target === "receive") {
                this.$emit(
                  "handleRecive",
                  this.formTop,
                  this.formTop.deviceMId
                );
              } else {
                this.$emit(
                  "handleDispath",
                  this.formTop,
                  this.formTop.deviceMId
                );
              }

              this.handleCancel();
              return;
            }

            this.loadingVisible = true;

            let url = "/dms/moldMaintenanceHall/add";
            if (this.target === "edit") {
              url = "/dms/moldMaintenanceHall/update";
              params["id"] = this.formTop.id;
            }
            this.axios({
              method: "post",
              url: url,
              data: params,
            }).then((res) => {
              if (res.code === 200) {
                this.deviceVisible = false;
                this.loadingVisible = false;
                this.formTop = {};
                if (this.tarGetid) {
                  this.$Message.success("操作成功！");
                  // this.$router.push({ path: "/maintenanceList" });
                } else {
                  this.$Message.success("操作成功！");
                  this.$emit("refresh");
                }
              } else {
                // this.deviceVisible = false;
                this.loadingVisible = false;
                this.$Message.error(res.msg);
              }
            });
          };

          let desc = "";
          if (!this.formTop.id)
            desc = this.$t("已存在未完工的维修单，是否确认继续报修？");
          if (this.formTop.id) {
            if (this.target === "receive") {
              desc = this.$t("已存在未完工的维修单，是否确认继续接单？");
            } else {
              desc = this.$t("已存在未完工的维修单，是否确认继续分配？");
            }
          }
          createOrder();
        }
      });
    },
    //获取班组列表
    getTeam() {
      getTeamList().then((res) => {
        if (res.code === 200) {
          this.teamList = res.data;
        } else {
          this.$Message.warning({
            content: res.msg,
            duration: 6,
            closable: true,
          });
        }
      });
    },
    //班组变化是
    teamChange(val) {
      if (!val) {
        return;
      }
      this.formTop.team = val;
      this.$set(this.formTop, "shift", "");
      this.axios({
        method: "get",
        url: "/dms/productionShift/selectByTeam",
        params: { teamName: val },
      }).then((res) => {
        this.shiftList = res.data;
        this.deviceVisible = true;
      });
    },
    //获取磨具信息
    // getMoldInfo(query) {
    //   // { moldCode: query }
    //   getMoldInfoList().then((res) => {
    //     if (res.code == 200) {
    //       this.moldInfoList = res.data.records;
    //     } else {
    //       this.$Message.warning({
    //         content: res.msg,
    //         duration: 6,
    //         closable: true,
    //       });
    //     }
    //   });
    // },
    getMoldInfo(val) {
      console.log(val,'val');
      this.moldCode = val;
      // this.formTop.moldCode=val
      return getMoldInfoList({ moldCode: val }).then((res) => {
        this.moldInfoList = res.data.records;
        this.$forceUpdate();
        return true;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.demo-upload-list {
  position: relative;
  width: 60px;
  height: 60px;
  text-align: center;
  line-height: 60px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  margin-left: 15px;

  img {
    width: 100%;
    height: 100%;
  }

  .delIcon {
    position: absolute;
    right: -10px;
    top: -10px;
    color: red;
    font-size: 20px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
  }
}
</style>
